package com.csun.dsms.comment.core.aspect;

import com.csun.dsms.comment.core.utils.wrapper.Wrapper;
import lombok.extern.slf4j.Slf4j;
import org.aspectj.lang.ProceedingJoinPoint;
import org.aspectj.lang.annotation.Around;
import org.aspectj.lang.annotation.Aspect;
import org.springframework.stereotype.Component;

@Slf4j
@Aspect
@Component
public class ExceptionAspect {
	@Around("within(com.csun.dsms.controller.*Controller)")
	public Object process(ProceedingJoinPoint target) {
		
		try{
			Object o = target.proceed();
			return o;
		} catch(Throwable e){
			log.error("runtime: {}", e.getMessage());
			e.printStackTrace();
			return new Wrapper(e);
		}
	}
}
